package com.ys.util.amazon;

import java.util.HashMap;
import java.util.Map;

import com.amazon.SellingPartnerAPIAA.AWSAuthenticationCredentials;
import com.amazon.SellingPartnerAPIAA.AWSAuthenticationCredentialsProvider;
import com.ys.config.MyConfig;
import com.ys.enume.RegionEnum;

public class AmazonUtil {
	
	public static Map<String, AWSAuthenticationCredentials> getCredentials() {
		Map<String, AWSAuthenticationCredentials> MAP_REGION_Credentials = new HashMap<String, AWSAuthenticationCredentials>();
		for(RegionEnum e : RegionEnum.values()) {
			AWSAuthenticationCredentials awsAuthenticationCredentials = AWSAuthenticationCredentials.builder()
					.accessKeyId(MyConfig.getAmazonAwsAccessKey()).secretKey(MyConfig.getAmazonAwsAccessSecret())
					.region(e.getAwsRegion()).build();
			MAP_REGION_Credentials.put(e.getCode(), awsAuthenticationCredentials);
		}
		return MAP_REGION_Credentials;
	}
	
	public static AWSAuthenticationCredentialsProvider getProvider() {
		return AWSAuthenticationCredentialsProvider
				.builder().roleArn(MyConfig.getAmazonRoleArn()).roleSessionName(MyConfig.getAmazonRoleSessionName())
				.build();
	}
}
